/*
 * Copyright 2010-2011 ESunny.com All right reserved. This software is the confidential and proprietary information of
 * ESunny.com ("Confidential Information"). You shall not disclose such Confidential Information and shall use it only
 * in accordance with the terms of the license agreement you entered into with ESunny.com.
 */
package com.xjt.query.entity;

import java.io.Serializable;
import java.util.LinkedHashMap;

import org.apache.commons.lang.builder.ReflectionToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import com.xjt.query.dao.pojo.Region;

/**
 * 区域实体
 * 
 * @author Jet Xu 2011-7-26 上午10:22:12
 */
public class RegionModel implements Serializable, Comparable<RegionModel>, Cloneable {

    private static final long                serialVersionUID = -4582086902605949579L;

    /** 区域ID */
    private Long                             regionId;

    /** 父节点ID */
    private Long                             parentId;

    /** 区域名称 */
    private String                           regionName;

    /** 子区域 */
    private LinkedHashMap<Long, RegionModel> children;

    public RegionModel(){

    }

    public RegionModel(Region region){
        if (null != region) {
            this.setRegionId(region.getRegionId());
            this.setParentId(region.getParentId());
            this.setRegionName(region.getRegionName());
        }
    }

    @Override
    public RegionModel clone() throws CloneNotSupportedException {
        return clone(true);
    }

    @SuppressWarnings("unchecked")
    public RegionModel clone(boolean deapClone) throws CloneNotSupportedException {
        RegionModel model = (RegionModel) super.clone();
        if (deapClone) {
            model.setChildren((LinkedHashMap<Long, RegionModel>) model.getChildren().clone());
        }
        return model;
    }

    /**
     * @return the children
     */
    public LinkedHashMap<Long, RegionModel> getChildren() {
        return children;
    }

    /**
     * @param children the children to set
     */
    public void setChildren(LinkedHashMap<Long, RegionModel> children) {
        this.children = children;
    }

    /**
     * @return the regionId
     */
    public Long getRegionId() {
        return regionId;
    }

    /**
     * @param regionId the regionId to set
     */
    public void setRegionId(Long regionId) {
        this.regionId = regionId;
    }

    /**
     * @return the parentId
     */
    public Long getParentId() {
        return parentId;
    }

    /**
     * @param parentId the parentId to set
     */
    public void setParentId(Long parentId) {
        this.parentId = parentId;
    }

    /**
     * @return the regionName
     */
    public String getRegionName() {
        return regionName;
    }

    /**
     * @param regionName the regionName to set
     */
    public void setRegionName(String regionName) {
        this.regionName = regionName;
    }

    @Override
    public String toString() {
        return ReflectionToStringBuilder.toString(this, ToStringStyle.SHORT_PREFIX_STYLE);
    }

    @Override
    public int compareTo(RegionModel o) {
        return 0;
    }

}
